<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Off the Record</title>   
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<script type="text/javascript">
	function searchMentor(){
		var f = document.searchForm;
		if(f.companyName.value==""){
			alert("회사명을 입력해주세요.");
			return f.companyName.focus();
		}
		
		f.submit();
	}
	
	function updateMentorPoint(mentorId){
		var i=confirm("포인트를 차감하시겠습니까?");
		if(i){
			$.ajax({
				type: "post",
				url: "/OffTheRecord/updateMentorPoint.action",
				data: "mentorUserId="+mentorId,
				dataType:"json",
				
				success:function(data){
						alert("포인트가 차감되었습니다.");
				}
			});//ajax
		}
	}
	
	function deleteMentor(mentorId, companyName){
		var i = confirm("멘토를 삭제하시겠습니까?");
		if(i){
			location.href="/OffTheRecord/deleteMentor.action?mentorId="+mentorId+"&&companyName="+companyName;
		}
	}
</script>
<body>
<c:import url="../common/top.jsp"></c:import>
<div class="container" style="margin: 60px;"></div>

<div class="container">
<div class="row">
<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>

<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<c:import url="admin_menu.jsp"/>
</div>
<!--  -->
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">

		<!-- 탭 -->
	<div class="bs-example bs-example-tabs" role="tabpanel">
		<ul id="myTab" class="nav nav-tabs" role="tablist">
			<li role="presentation" class="active"><a href="#home" id="home-tab" role="tab" data-toggle="tab" aria-controls="home" aria-expanded="true">멘토 검색/포인트 차감/삭제 <span class="glyphicon glyphicon-user"></a></li>
	  	</ul>
	    
	    <div id="myTabContent" class="tab-content">
			<div role="tabpanel" class="tab-pane fade in active" id="home" aria-labelledBy="home-tab">
		   			
			<div class="user-update col-lg-12" style="padding: 10px;">
			<!--  -->

	<!--  -->
	<div class="user-id-search col-lg-12" style="background-color: lightgray; border: 1px solid lightgray; border-radius: 5px; padding: 10px;">
		<form class="form" role="form" name="searchForm" action="/OffTheRecord/getAllMentorByCompanyName.action">
			<div class="input-group">
					<input list="companyName" class="form-control" placeholder="기업 명으로 멘토를 검색해주세요" name="companyName" id="company_name">
						<datalist id="companyName">
							<c:forEach items="${clist }" var="clist">
								<option id="clist" value="${clist.companyName}">
							</c:forEach>
						</datalist>
					<span class="input-group-btn">
					<button type="submit" class="btn btn-default" id="SubmitBtn" onclick="searchMentor()">검색</button>
					</span>
			</div>
		</form>
	</div>
	
	<div class="page-header">
				<hr>
	</div>

<!--  -->
<div class="col-xs-12 col-sm-12 col-md-12- col-lg-12">
<div class="bs-example">
      <div class="table-responsive">
      	<c:if test="${fn:length(mlist) == 0}">
          	<tr><td>검색 결과가 없습니다.</td></tr>
         </c:if>
         <c:if test="${fn:length(mlist) != 0}">
        <table class="table table-hover">
        
          <thead>
            <tr>
              <th>#</th>
              <th>mentor_name</th>
              <th>Point</th>
              <th>Delete</th>
            </tr>
          </thead>
          
          <tbody>
           	<c:forEach items="${requestScope.mlist }" var="mvo" varStatus="i">
           	 	<tr>
	           		<td>${i.count }</td>
	             	<td>${mvo.mentorUserId }</td>
	            	<td><button class="btn btn-default" onclick="updateMentorPoint('${mvo.mentorUserId }')">포인트 차감</button></td>
	           	 	<td><button class="btn btn-default" onclick="deleteMentor('${mvo.mentorId }','${mvo.companyVo.companyName }')">삭제</button></td>
           	 	 </tr>
           	</c:forEach>
              
          </tbody>
          
        </table>
        </c:if>
      </div><!-- /.table-responsive -->

    </div>

</div>




			<!--  -->
			</div>
						
			</div>
		</div>
	</div><!-- End 탭 -->





</div>
<!--  -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
<!--  -->
</div>

<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>
</div><!-- row -->
</div><!-- container -->

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>   
</body>
</html>